package org.yaonan.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yaonan.bean.YnMessage;
import org.yaonan.bean.YnUser;
import org.yaonan.dao.YnMessageMapper;
import org.yaonan.service.YnMessageService;
@Service
public class YnMessageServiceImpl implements YnMessageService {

	@Autowired
	private YnMessageMapper ynMessageMapper;
	@Override
	public List<YnUser> selectMessageByUserid(Integer userid) {
		return ynMessageMapper.selectMessageByUserid(userid);
	}
	@Override
	public List<YnMessage> selectMessageByFriendid(Integer userid, Integer friendid, Integer count) {
		List<YnMessage> list = ynMessageMapper.selectMessageByFriendid(userid, friendid, count);
		ynMessageMapper.deleteMessage(userid, friendid);
		return list;
	}
	@Override
	public int selectMessageCount(Integer userid) {
		return ynMessageMapper.selectMessageCount(userid);
	}
	@Override
	public Date selectNewMessageTime(Integer userid) {
		return ynMessageMapper.selectNewMessageTime(userid);
	}
	@Override
	public int insertSelective(YnMessage ynMessage) {
		return ynMessageMapper.insertSelective(ynMessage);
	}
	@Override
	public List<YnMessage> selectGetNewMessage(Integer userid, Integer friendid) {
		List<YnMessage> list = ynMessageMapper.selectGetNewMessage(userid, friendid);
		ynMessageMapper.updateNewMessageRead(userid, friendid);
		return list;
	}

}
